package com.srlg.webflux.dao;

import com.srlg.webflux.entity.Book;

import reactor.core.publisher.Mono;

import org.springframework.data.r2dbc.repository.Query;
import org.springframework.data.r2dbc.repository.R2dbcRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

/**
 * @desc:
 * @author: srlg li
 * @date: 2024/1/7 15:49
 */
@Repository
public interface BookDao extends R2dbcRepository<Book, Long> {

    @Query("""
        select b.*, a.name as name from t_book b left join t_author a
        on b.id = a.id
        where b.id = :id
            """)
    Mono<Book> findBookAndAuthorById(@Param("id") Long id);
}
